<template>
	<view class="">
	<button @click="connect">connect</button>
	</view>
</template>

<script setup>
	import nacl from 'tweetnacl';
	import naclUtil from 'tweetnacl-util';
	
	const connect = ()=>{
		// 生成公私钥对
		const keyPair = nacl.box.keyPair();
		
		// 获取私钥（base58编码）
		const privateKey = naclUtil.encodeBase58(keyPair.secretKey);
		
		// 获取公钥（base58编码）
		const publicKey = naclUtil.encodeBase58(keyPair.publicKey);
		
		const appUrl = encodeURIComponent("http://cxc.firo.asia/#/");  // 用您的应用 URL 替换
		const encryptionPublicKey = publicKey;  // 替换为您的加密公钥
		const redirectLink = encodeURIComponent("hbuilder://pages/index/index");  // 用您的回调 URL 替换
		
		const phantomUrl = `https://phantom.app/ul/v1/connect?app_url=${appUrl}&dapp_encryption_public_key=${encryptionPublicKey}&redirect_link=${redirectLink}`;
		plus.runtime.openURL(phantomUrl);  // 打开 Phantom 钱包进行连接

		
	}
</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}
</style>
